package ext.tianma.forms.processors;

import java.util.ArrayList;
import java.util.List;

import wt.util.WTException;

import com.ptc.core.components.beans.ObjectBean;
import com.ptc.core.components.forms.FormProcessorHelper;
import com.ptc.core.ui.resources.ComponentMode;
import com.ptc.netmarkets.util.beans.NmCommandBean;
import com.ptc.windchill.enterprise.change2.forms.controllers.DefaultChangeTaskFormProcessorController;

public class CusDefaultChangeTaskFormProcessorController extends DefaultChangeTaskFormProcessorController{
	
	public CusDefaultChangeTaskFormProcessorController(){
		super();
	}
	
	@Override
	protected ObjectBean getFormObjectBean(NmCommandBean nmcommandbean, ObjectBean objectbean)
			throws Exception {
		ObjectBean objbean = getEffectivityIframeFormObjectBean(nmcommandbean, objectbean);
	    if (!isDefaultChangeTaskHandled(nmcommandbean))
	    {
	      NmCommandBean nmbean = new NmCommandBean();
	      nmbean.addRequestDataParam("iframeId", "defaultChangeTask", false);
	      nmbean.addRequestDataParam("operation", ComponentMode.CREATE.toString(), false);
	      ObjectBean obtbean = FormProcessorHelper.getCurrentObjectBean(nmbean);
	      obtbean.setDelegateClassNames(new ArrayList());
	      
	      //obtbean.setProcessorClassName(DefaultChangeTaskFormProcessor.class.getName());
	      obtbean.setProcessorClassName(CusDefaultChangeTaskFormProcessor.class.getName());
	      
	      List list = objectbean.getChildren();
	      list.add(obtbean);
	      objbean.setChildren(list);
	    }
	    return objbean;
	}
	
	protected ObjectBean getEffectivityIframeFormObjectBean(NmCommandBean nmcommandbean, ObjectBean objectbean) throws Exception{
		return super.getFormObjectBean(nmcommandbean, objectbean);
	}
	
	
	@Override
	protected boolean defaultChangeTaskDeleted(NmCommandBean nmcommandbean) {

		return super.defaultChangeTaskDeleted(nmcommandbean);
	}

	@Override
	protected boolean defaultChangeTaskExists(NmCommandBean nmcommandbean)
			throws WTException {

		return super.defaultChangeTaskExists(nmcommandbean);
	}

	@Override
	protected String getTableId(String tableid, NmCommandBean nmcommandbean) {

		return super.getTableId(tableid, nmcommandbean);
	}

	@Override
	protected boolean isDefaultChangeTaskHandled(NmCommandBean nmcommandbean)
			throws WTException {

		return super.isDefaultChangeTaskHandled(nmcommandbean);
	}

}
